<?php
/**
* @author: Pham Van Diep
* @date: 21/2/2014
*/
// check permission add new
if( !isset($AppUI) ||	
    !isset($_SESSION['personal'])||
    !isset($_GET['personalid'])	    
) {
	redirect(HOST_BACKEND);
}
$intClubId    = intval($_GET['clubid']);
$intSponsorId = intval($_GET['personalid']);
$intUserRole  = $AppUI->type;
switch($intUserRole){
    case ROLE_ROOT:
        $objSps = $this->personal->get($AppUI->id,$intSponsorId);
        $ret = $this->personal->delete($AppUI->id,$intSponsorId);
        // remove logo file
        if($ret == 0) {
            $strLogo = $objSps->logo;
            unlink(DATA_UPLOAD_DIR.substr($strLogo,strlen(HOST_UPLOAD),strlen($strLogo)));
        }
        break;
    case ROLE_ADMINISTRATOR:
        $ret = $this->personal->updateStatus($AppUI->id,$intSponsorId,6,2);
        break;
    case ROLE_LEADER:
        $ret = $this->personal->updateStatus($AppUI->id,$intSponsorId,5,2);
        break;
    case ROLE_MEMBER:
        $ret = $this->personal->updateStatus($AppUI->id,$intSponsorId,3,2);
        break;
    case ROLE_FREELANCER:
        break;
    default:
        break;
        
}
redirect(HOST_BACKEND . 'personal/index?clubid='.$intClubId);
